<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class OrderInvalid extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'order:invalid';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '修改24小时之前的未支付订单状态为失效 3';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $data['status'] = 3;
        $data['updated_at'] =date("Y-m-d H:i:s");
        $startTime = date("Y-m-d H:i:s",strtotime("-1 day"));
        DB::table('payment_orders')
            ->where('status', 1)
            ->whereDate('created_at', '<' ,$startTime)
            ->update($data);
        echo '修改24小时之前的未支付订单状态为失效 3 完成';
    }
}
